GBML manual / Drawing

sprite_effect_start

Plays a sprite effect on this object only: a hit flash, a freeze tint, a dizzy wobble, a ghost. A sprite effect is made in the Overlay Effects tab, like a screen effect, but it changes one object instead of the whole screen. Starting another one on the same object replaces the first. sprite_effect_start(nothing) stops it.

Works differently on Game Boy - The Game Boy plays the Tint through its 4 shades, See-through as flicker, Blocks with pictures made ahead of time; Wobble and Distort bend one small picture; Scale and Rotate show the nearest picture made ahead of time.

Works differently on Game Boy Color - The Game Boy Color plays the Tint exactly, See-through as flicker, Blocks with pictures made ahead of time; Wobble and Distort bend one small picture; Scale and Rotate show the nearest picture made ahead of time.

Works differently on Sega Genesis - The Sega Genesis plays a sprite effect its own way. This version plays the Tint track (the object's colors mixed toward the effect's color, with the effect's timing). A sprite cannot be bent, turned, resized, blocked or faded here, so the Wobble, Distort, Scale, Rotate, Blocks and See-through tracks do not show (the build says which effect has one); use Make a sprite from this effect for those.

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

sprite_effect_start(effect)

Arguments

NameType
effectoverlay

Returns

Nothing.

Description

Plays a sprite effect on this object only: a hit flash, a freeze tint, a dizzy wobble, a ghost, a teleport. A sprite effect is made in the Overlay Effects tab, like a screen effect, but it changes one object instead of the whole screen. Starting another one on the same object replaces the first. sprite_effect_start(nothing) stops it.

Call it from the object's own event, for example when the object gets hit:

Example

sprite_effect_start(se_doc_hit);

The walker flashes white for a moment and then looks the way it did before.

What an effect is made of

A sprite effect has up to seven tracks. Every track is optional and has its own way of moving:

Tick Play backwards to run a pulse the other way round: it starts at full strength and falls to nothing (when it repeats, it then jumps back to full). It is grayed out for Stands still, Pulse reverse and Fade back, which have nothing to turn around.

Start after. Every track's way-of-moving row has a Start after box: the number of frames the track waits before it begins. Until then it is not there at all (a Scale or Rotate shows the first number of its graph); then it runs its own way of moving from its first frame. 0 starts it with the effect. Blocks and See-through have no Start after (the screen plays them), and the whole effect has none: only a track can wait.

TrackWhat it does to the object
Tintmixes the object's colors toward a color, or toward a palette of your project. Give it up to 6 colors and it moves through them in order as the strength rises, reaching the last at full strength (colors or a palette, not both). A white Tint is a hit flash
Wobblepushes each row of the object sideways: a wave, a sway, a ripple, a flag in the wind, a glitch... (see The looks of Wobble and Distort below), like sprite_warp
Distortsqueezes, stretches, melts, flips or mirrors the object: a barrel, a leaning sign, a coin turning, a TV switching off... (see below), like sprite_distort
Blocksturns the object into big blocks
See-throughlets you see through the object
Scalemakes the object bigger or smaller, in percent. It is multiplied with the size the object already has (its xscale and yscale). Tick Scale individually to give the width and the height a graph each
Rotateturns the object, in degrees. It is added to the angle the object already has; a positive number turns it counter-clockwise, like angle

Scale and Rotate are graphs over the track's own motion: the top of the graph is the start of the motion and the bottom is its end. A track that stands still stays at the top; a pulse goes down the graph once (or again and again); a pulse that plays once and is over leaves the object as it was. The console draws a picture inside a box twice its size, so an object cannot be shown bigger than 200 percent: past that it is cut off.

The looks of Wobble and Distort

A Wobble slides each row of the object's picture to the left or right. Pick its look:

LookWhat it doesHow far at strength 1, 2, 3
Wave, Drunk, Shake, Zigzag, Shimmer, Driftthe original six: a smooth wave, a slow wide sway, a buzz, straight lines with sharp turns, quick small ripples, one long lazy curve1 to 7 pixels
Ripplerings of waves spread up and down from the middle row2, 3, 5 pixels
Flagthe top stays put and the sway grows toward the bottom, like a banner, a curtain or a ghost's tail2, 4, 6 pixels
Winda gust leans the object one way, it springs back and settles, and the gusts come again and again; the feet stay put3, 5, 8 pixels
Boingone hard sideways jiggle that dies away, again and again; the feet move less than the head4, 7, 11 pixels
Twistthe middle rows swing furthest and the top and the bottom lag behind, as if the object were wrung out3, 5, 8 pixels
Interlaceevery other row moves the opposite way, like a bad TV signal1, 2, 3 pixels
Glitch tearrandom bands of rows jump sideways for a moment and snap back; most of the time the object is clean, and the first moment always has a tear3, 6, 10 pixels
Slitherone long slow wave travels from the top to the bottom, like a snake3, 5, 8 pixels

A Distort decides which row of the picture each row of the screen shows, and how wide it is drawn. The console draws a Distort inside a box twice as wide and tall as the picture, so the object can grow past its own edges, up to twice its size:

LookWhat it doesStrength 1, 2, 3
Wave, Bulge, Pinch, Lean back, Lean forwardthe original five: a jelly wave, a barrel, a waist, a sign tipped back or forwardhow much narrower the narrowest row is
Meltthe object sags down toward its feet and spreads wider at the bottom, like waxdown to 75, 55 or 35 percent of its height
Squash & stretchthe object is squashed flat and wide, then stretched tall and thin, again and again, with its feet staying where they are16, 28 or 41 percent
Flipthe object squeezes to a thin line and opens again, like a coin or a card turningnarrows to 57 percent, 26 percent, or all the way to a line
TV offthe object collapses to a single line, the line shrinks, and then it is gone, like an old TV switching offstrength 1 a thin band, 2 a single short line, 3 nothing at all: the strength is how far it goes
Reflectionthe lower part shows the upper part upside down, like waterthe line is a sixth, a third or half of the height above the feet
Sinkthe object slides down into the ground; what is below its feet is not showna third, two thirds or all of its height. Use Play backwards to make it come up out of the ground
Risethe opposite: the object slides up and out of its place; what is above its head is not shownthe same
Shredbands of the picture show other rows, out of order, with a new set every few framesup to 4, 8 or 12 rows away
Boba gentle wave of rows moves up the object, as if it were floating1, 2 or 3 rows
Tipthe object rocks forward and back like a card standing on its feet, in perspective: the top that tips toward you gets wider, the top that tips away narrower, and the feet stay on the groundtips 25, 39 or 53 degrees
Tip (about the middle)the same rocking card, but about its middle: the near edge gets wider and taller, the far edge narrower and shorter, and the feet lift off the groundthe same
Bend squasha landing squash that bends: the feet stay down, the object is crushed flat and its middle swells out sideways, then it springs tall and thin and settlessquashes by 22, 38 or 53 percent

Good to know:

The console has one block size and one see-through level

Blocks and See-through are different from the other four. The Game Boy Advance has one block size and one see-through level for the whole screen. So these two tracks cannot be private to an object. What the effect does is mark the object, and the screen's block size and see-through level then reach that object (and whatever else you marked blocky or see-through yourself).

Because of that:

Tint, Wobble and Distort are private to the object: as many objects as you like (up to 8 at once) can have them.

On an object lit by room lights

A sprite effect's Tint on a lit object is mixed over its own colors, not the light's. The Tint does not change with the light: it stays as it is while the object walks into a light, out of it or between lights, and a Tint that is held stays steady for as long as it is held. When the Tint ends, the object wears whatever the light gives it at that moment. See Room lighting.

When it ends

An effect ends by itself when every track it has is a pulse that plays once, and the longest has played. If any track stands still, repeats or holds, it plays until you call sprite_effect_stop, start another effect on the object, or the object is destroyed or its room ends. The object gets its own colors back when the effect ends.

On the Game Boy Advance

On the GBA

An effect has up to five tracks, each with its own way of moving (standing still, a pulse that plays once, repeats or holds). Tint gives the object a palette of its own while it plays (its own colors mixed toward a color, or toward a palette of the project): that takes one of the console’s 16 sprite palettes for as long as it lasts, and a new one each time the amount changes, and the object’s own palette comes back when it ends. Wobble and Distort are sprite_warp and sprite_distort asked for a strength that follows the pulse: one or two of the console’s 8 row-by-row effects (Distort also one of its 32 matrices), only while the object has a picture on the screen. Blocks and See-through are different: the console has ONE block size and ONE see-through level for the whole screen, so they belong to the screen, not to the object. The object is marked blocky or see-through (sprite_blocky, sprite_see_through) and the screen’s value plays while the effect does. Because of that, only one sprite effect with a Blocks or See-through track can play at a time, and it replaces an overlay_start effect of your own. A second one is refused: a development build stops with a message that says so, a release build plays the rest of that effect without those two tracks. Up to 8 objects can have a sprite effect at once. The effect ends by itself when every track is a pulse that plays once and the longest is over; any track that stands still, repeats or holds means it plays until sprite_effect_stop, a new sprite_effect_start, or the object is destroyed. Call it from the object’s own event. Called straight inside a Draw event, it applies to every picture the object draws until sprite_effect_stop (draw_self and every draw_sprite), frame after frame, and its clock runs on between frames: the stop closes the brackets, it does not end the effect. Called anywhere else it works on the picture the engine draws for the object by itself (and, for See-through and Blocks, everything the object draws, text included). A game that never plays a sprite effect has none of this in its cartridge.

See also: Overlay effects - screen effects you make yourselfsprite_effect_stopsprite_effect_activeoverlay_startsprite_palettesprite_warpsprite_distortsprite_see_throughsprite_blocky